import redis

# 连接集群
startup_nodes = [
    {"host": "redis-cluster-0.redis-cluster", "port": 6379},
    {"host": "redis-cluster-1.redis-cluster", "port": 6379},
    {"host": "redis-cluster-2.redis-cluster", "port": 6379}
]

r = redis.RedisCluster(
    startup_nodes=startup_nodes,
    decode_responses=True,
    skip_full_coverage_check=True
)

# 操作数据
r.set("key1", "value1")
r.set("key2", "value2")
print(r.get("key1"))
